# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=simage

pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}-hg"
pkgver=r671.2dab4dadbb2e
pkgrel=1
pkgdesc="Provides support for loading and saving images, sound and video (mingw-w64)"
arch=('any')
license=('BSD')
depends=("${MINGW_PACKAGE_PREFIX}-libjpeg-turbo"
    "${MINGW_PACKAGE_PREFIX}-libpng"
    "${MINGW_PACKAGE_PREFIX}-libsndfile"
    "${MINGW_PACKAGE_PREFIX}-libtiff"
    "${MINGW_PACKAGE_PREFIX}-giflib"
    "${MINGW_PACKAGE_PREFIX}-libvorbis"
    "${MINGW_PACKAGE_PREFIX}-jasper"
    "${MINGW_PACKAGE_PREFIX}-zlib")
makedepends=("mercurial" "${MINGW_PACKAGE_PREFIX}-cmake" "${MINGW_PACKAGE_PREFIX}-gcc")
provides=("${MINGW_PACKAGE_PREFIX}-${_realname}")
conflicts=("${MINGW_PACKAGE_PREFIX}-${_realname}")
url=('https://bitbucket.org/Coin3D/simage/overview')
source=("${_realname}"::"hg+https://bitbucket.org/Alexpux/simage")
options=(!strip staticlibs)
md5sums=('SKIP')

pkgver() {
  cd "$srcdir/$_realname"
  printf "r%s.%s" "$(hg identify -n)" "$(hg identify -i)"
}

prepare() {
  cd ${srcdir}/${_realname}
}

build() {
  [[ -d "${srcdir}/build-${MINGW_CHOST}" ]] && rm -rf ${srcdir}/build-${MINGW_CHOST}
  mkdir ${srcdir}/build-${MINGW_CHOST}
  cd ${srcdir}/build-${MINGW_CHOST}
  ../"${_realname}"/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --enable-shared \
    --disable-static \
    --enable-optimization \
    --disable-html \
    --disable-debug \
    --with-targa \
    --with-rgb \
    --with-xwd \
    --with-eps \
    --with-gif=${MINGW_PREFIX} \
    --with-jpeg=${MINGW_PREFIX} \
    --with-zlib=${MINGW_PREFIX} \
    --with-png=${MINGW_PREFIX} \
    --with-tiff=${MINGW_PREFIX} \
    --with-jasper=${MINGW_PREFIX} \
    --with-oggvorbis=${MINGW_PREFIX} \
    --with-libsndfile=${MINGW_PREFIX} \
    --without-x \
    --without-gdiplus \
    --without-doxygen
  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR=${pkgdir} install
}
